home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8866 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: su2.muelec.fpms.ac.BE!not-for-mail
  2. From: Jean-Marc Bourguet <bourguet@muelec.fpms.ac.be>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Object Oriented programming in C ????
  5. Date: 07 Mar 1996 11:23:28 +0100
  6. Organization: Faculte Polytechnique de Mons, Service d'Electronique
  7. Sender: bourguet@su2
  8. Message-ID: <sgbum9nqvz.fsf@su2>
  9. References: <4higq7$5j2@sidhe.memra.com>
  10.     <4hkor1$3pu@dfw-ixnews1.ix.netcom.com>
  11. NNTP-Posting-Host: su2.muelec.fpms.ac.be (193.190.210.14)
  12. X-Access: 16 727
  13. In-reply-to: a1s@ix.netcom.com's message of Wed, 06 Mar 1996 22:18:27 GMT
  14. X-Newsreader: Gnus v5.0.12
  15.  
  16. a1s@ix.netcom.com (Andrew Snyder) writes
  17. > michael@memra.com (Michael Dillon) wrote:
  18. > >Does anyone know of resources that explain how to write OO programs in C?
  19. > >I know about C++ and Objective C and I don't like either one. I would 
  20. > >like to be able to write OO programs in straight C (with some 
  21. > >preprocessor help for syntactic sugar) so that my code is fully portable 
  22. > >between a number os OS's.
  23. > There is no magic to OO design that requires a particular language,
  24. > all you need to do is hide the implementation of your "objects" behind
  25. > a set of function calls.  The file handling provided by "stdio.h" is a
  26. > good example:
  27. > 1) All possible operations on files map to a paticular function call.
  28. > 2) The detail of files are "hidden" from the user-programmer.
  29. > 3) Files can be different things on different systems (i.e. disk file,
  30. > pipe, tape drive)
  31. > What an OO language will get you is better support for things like
  32. > initialization, real information hiding, type checking, etc.
  33.  
  34. OO languages provide more than data abstraction... What is important
  35. for me in OO language is
  36.    - inheritance : the possibility to define derivative of a type
  37. (class in the C++ terminology) and to use derivative everywhere the
  38. base type may be used;
  39.    - late binding : the possibility to use functions which depend on
  40. the true type of one parameter (virtual methods in the C++
  41. terminology).
  42.  
  43. > Just build a function library and hide as much stuff as you can with
  44. > static variables.  Be sure to include the libraries header file in
  45. > every c file to catch errs.
  46. -- 
  47.  Jean-Marc Bourguet                      Service d'Electronique
  48.                                          Faculte polytechnique de Mons
  49.  Email : bourguet@muelec.fpms.ac.be      Mons, Belgique
  50.